package br.perfiman.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
 *
 * @author Wagner Costa
 * @since 27/12/2007
 * @version 1.0
 *
 */
@Entity
public class Asset implements AbstractEntity{
	private static final long serialVersionUID = -3077743115906309405L;

	public static final int TYPE_FULL = 1;
	public static final int TYPE_FRACTIONAL = 2;
	public static final int TYPE_OPTIONS = 3;

	@Id
    @GeneratedValue
    protected Long id;

    @Column(length=10, unique=true, nullable=false)
    protected String symbol;

    @Column(length=50, nullable=false)
    protected String name;

    @Column(nullable=false)
    protected Integer type;
    
	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getSymbol() {
		return symbol;
	}

	public Integer getType() {
		return type;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Object getEntityId() {
		return getId();
	}

	@Override
	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append("id: ").append(getId());
		b.append("; Symbol: ").append(getSymbol());
		b.append("; Name: ").append(getName());
		b.append("; Type: ").append(getType());
		return b.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((symbol == null) ? 0 : symbol.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Asset other = (Asset) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (symbol == null) {
			if (other.symbol != null)
				return false;
		} else if (!symbol.equals(other.symbol))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}
}